package com.ourhealth.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * 检查项通知
 **/
@Component
@Aspect
public class CheckItemAspect {

    /**
     * aop 重用表达式
     */
    @Pointcut("execution(public com.ourhealth.pojo.CheckItem com.ourhealth.service.CheckItemService.findCheckItemById(int))")
    public void declareJointPointExpression() {

    }

    /**
     * 前置通知
     *
     * @param joinPoint
     */
    @Before("declareJointPointExpression()")
    public void before(JoinPoint joinPoint) {
        System.out.println("正在查询");
    }

    /**
     * 后置通知
     *
     * @param joinPoint
     * @param returnVal
     */
    @AfterReturning(value = "declareJointPointExpression()", returning = "returnVal")
    public void afterReturning(JoinPoint joinPoint, Object returnVal) {
        System.out.println("已查完：" + returnVal);
    }
}